library(JointNets)
graphics.off()
par(ask = FALSE)
par(mfrow = c(1, 1))
## (simulation) simulate samples of two groups
simulationresult = simulation(n=c(100,100))
AUC_result = AUC(simulationresult,
                 gm_method = "diffee",
                 lambdas = seq(0.1,2,0.05))
truth = simulationresult$simulatedgraphs
## (learning) compute results for diffee
result = diffee(simulationresult$simulatedsamples[[1]], simulationresult$simulatedsamples[[2]], 0.45)
## (visualiation) plot estimated graph
layout = layout_nicely(returngraph(result))
plot(result,layout = layout)
plot(truth, subID = 0, layout = layout)
data(nip_37_data)
label = colnames(nip_37_data[[1]])
result = simule(
  nip_37_data,
  lambda = 0.13,
  epsilon = 0.5,
  covType = "kendall"
)
graph = returngraph(result)
layout = layout_nicely(graph, dim = 2)
par(mfrow = c(1, 1))
plot(result, type = "task", layout = layout)
  plot(result, type = "share", layout = layout)
  plot(result,
       type = "taskspecific",
       subID = 1,
       layout = layout)
  plot(result,
       type = "taskspecific",
       subID = 2,
       layout = layout)
plot_gui()
## (evaluation) evaluate diffee performance
{
  cat(paste("AUC score: ", AUC_result$auc))
  cat("\n")
  cat("F1 score difference: ")
  cat(F1(result,truth)$difference)
  cat("\n")
  plot(AUC_result$fPM,AUC_result$tPM, xlab = "False Positive Rate", ylab = "True Positive Rate", main = "ROC")
  lines(AUC_result$fPM[order(AUC_result$fPM)], AUC_result$tPM[order(AUC_result$fPM)], xlim=range(AUC_result$fPM), ylim=range(AUC_result$tPM))
}
## (application) classification using QDA
split = train_valid_test_split(simulationresult$simulatedsamples,c(0.6,0.2,0.2),1000)
train = split[["train"]]
valid = split[["valid"]]
test = split[["test"]]

v_seeking_length = 200
lambda_range = seq(0.1,0.3,length.out = 50)
result = QDA_eval(train,valid,test,lambda_range, v_seeking_length, method = "diffee")

result[["best test accuracy"]]


QData/JointNets documentation built on Nov. 17, 2019, 3:04 p.m.